package com.drug.web.controller.wms;

import java.util.List;

import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.drug.common.annotation.Log;
import com.drug.common.core.controller.BaseController;
import com.drug.common.core.domain.AjaxResult;
import com.drug.common.enums.BusinessType;
import com.drug.wms.domain.BusGoodsCategoryInfo;
import com.drug.wms.service.IBusGoodsCategoryInfoService;
import com.drug.common.utils.poi.ExcelUtil;
import com.drug.common.core.page.TableDataInfo;

/**
 * 商品类别信息Controller
 * 
 * @author ruoyi
 * @date 2021-11-12
 */
@Api("商品类别信息")
@RestController
@RequestMapping("/goodsC/info")
public class BusGoodsCategoryInfoController extends BaseController
{
    @Autowired
    private IBusGoodsCategoryInfoService busGoodsCategoryInfoService;

    /**
     * 查询商品类别信息列表
     */
    @ApiOperation("查询商品类别信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品类别主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryNo", value = "商品类别编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryName", value = "商品类别名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryUnitNo", value = "单位编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryRemark", value = "备注", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryClassification", value = "分类", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusGoodsCategoryInfo busGoodsCategoryInfo)
    {
        startPage();
        PageHelper.orderBy("create_time desc");
        List<BusGoodsCategoryInfo> list = busGoodsCategoryInfoService.selectBusGoodsCategoryInfoList(busGoodsCategoryInfo);
        return getDataTable(list);
    }

    /**
     * 导出商品类别信息列表
     */
    @ApiOperation("导出商品类别信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品类别主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryNo", value = "商品类别编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryName", value = "商品类别名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryUnitNo", value = "单位编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryRemark", value = "备注", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryClassification", value = "分类", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:export')")
    @Log(title = "商品类别信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BusGoodsCategoryInfo busGoodsCategoryInfo)
    {
        List<BusGoodsCategoryInfo> list = busGoodsCategoryInfoService.selectBusGoodsCategoryInfoList(busGoodsCategoryInfo);
        ExcelUtil<BusGoodsCategoryInfo> util = new ExcelUtil<BusGoodsCategoryInfo>(BusGoodsCategoryInfo.class);
        return util.exportExcel(list, "商品类别信息数据");
    }

    /**
     * 获取商品类别信息详细信息
     */
    @ApiOperation("获取商品类别信息详细信息")
    @ApiImplicitParam(name = "id", value = "商品类别信息id", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class)
    @PreAuthorize("@ss.hasPermi('system:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(busGoodsCategoryInfoService.selectBusGoodsCategoryInfoById(id));
    }

    /**
     * 新增商品类别信息
     */
    @ApiOperation("新增商品类别信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品类别主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryNo", value = "商品类别编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryName", value = "商品类别名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryUnitNo", value = "单位编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryRemark", value = "备注", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryClassification", value = "分类", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:add')")
    @Log(title = "商品类别信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusGoodsCategoryInfo busGoodsCategoryInfo)
    {
        return toAjax(busGoodsCategoryInfoService.insertBusGoodsCategoryInfo(busGoodsCategoryInfo));
    }

    /**
     * 修改商品类别信息
     */
    @ApiOperation("修改商品类别信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "商品类别主键编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryNo", value = "商品类别编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryName", value = "商品类别名称", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryUnitNo", value = "单位编号", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryRemark", value = "备注", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "categoryClassification", value = "分类", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "validityCode", value = "数据状态", dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "deptId", value = "部门ID", dataType = "String", dataTypeClass = String.class)
    })
    @PreAuthorize("@ss.hasPermi('system:info:edit')")
    @Log(title = "商品类别信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusGoodsCategoryInfo busGoodsCategoryInfo)
    {
        return toAjax(busGoodsCategoryInfoService.updateBusGoodsCategoryInfo(busGoodsCategoryInfo));
    }

    /**
     * 删除商品类别信息
     */
    @ApiOperation("删除商品类别信息")
    @ApiImplicitParam(name = "ids", value = "商品类别ids", required = true,allowMultiple = true, dataType = "String", paramType = "path", dataTypeClass = String.class)
    @PreAuthorize("@ss.hasPermi('system:info:remove')")
    @Log(title = "商品类别信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busGoodsCategoryInfoService.deleteBusGoodsCategoryInfoByIds(ids));
    }
}
